package com.runen.infinitemovement.adapter;

import android.content.Context;
import android.text.Html;
import android.text.TextUtils;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.runen.infinitemovement.R;
import com.runen.infinitemovement.model.entity.LikeListEntity;
import com.runen.infinitemovement.tool.CommonUtil;

/**
 * Create by LiaoDuanHong
 * Create on
 */
public class LikeListAdapter extends BaseQuickAdapter<LikeListEntity.DataBean, BaseViewHolder> {
    private Context context;

    public LikeListAdapter(Context context) {
        super(R.layout.item_like_list);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, LikeListEntity.DataBean dataBean) {
        TextView tv_content = baseViewHolder.findView(R.id.tv_content);
        String text = "<font color='#F63E5A'>%s <font/>%s <font color='#F63E5A'>%s <font/>%s";
        String text1 = "<font color='#F63E5A'>%s <font/>%s %s %s";
        if (!TextUtils.isEmpty(dataBean.toNickName)) {
            baseViewHolder.setText(R.id.tv_content,
                    Html.fromHtml(String.format(text, dataBean.nickName, dataBean.copywritingA, dataBean.toNickName, dataBean.copywritingB)));
        } else {
            baseViewHolder.setText(R.id.tv_content,
                    Html.fromHtml(String.format(text1, dataBean.nickName, dataBean.copywritingA, dataBean.copywritingB, dataBean.copywritingC)));
        }
        if (getItemPosition(dataBean) == getData().size() - 1) {
            LinearLayout.LayoutParams lp = (LinearLayout.LayoutParams) tv_content.getLayoutParams();
            lp.bottomMargin = CommonUtil.dp2px(context, 28);
            tv_content.setLayoutParams(lp);
        }
    }
}
